package com.score.controller;

import com.score.pojo.ReturnEntry;
import com.score.pojo.TUser;
import com.score.service.impl.StucadresServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class StucadresController {
    @Autowired
    private StucadresServiceImpl stucadresService;

    //获取所有干部信息
    @ApiOperation("获取所有干部信息")
    @Secured("ROLE_administrators")
    @GetMapping("/getAllStucadres")
    public ReturnEntry getAllStucadres(String college,
                                       @RequestParam(defaultValue = "1") Integer currentPage,
                                       @RequestParam(defaultValue = "10") Integer pageSize) {
        return stucadresService.getAllStucadres(college,currentPage, pageSize);
    }

    //添加查寝人员信息
    @Secured("ROLE_administrators")
    @PostMapping("/addStucadres")
    public ReturnEntry addStucadres(String username,String name,String college, String password) {
        return stucadresService.addStucadres(username,name,college, password,3);
    }

    //删除查寝人员信息
    @Secured("ROLE_administrators")
    @DeleteMapping("/deleteStucadres")
    public ReturnEntry deleteStucadres(@RequestParam(value = "ids") List<Integer> ids) {
        return stucadresService.deleteStucadres(ids);
    }
}
